/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

/**
 *
 * @author Admin
 */
public class nowaBean {

private String login="";
private String pass="";
private String mail="";
private String nazwa="";
private String[][] dane;
//public db.dbm db=new db.dbm();
public nowaBean(){
 ///   tekst1=new String("");
    }

     public void setLogin(String tekst){
        this.login=tekst;
    }
    public String getLogin(){
        return this.login;
    }
     public void setNazwa(String tekst){
        this.nazwa=tekst;
    }
    public String getNazwa(){
        return this.nazwa;
    }
     public void setMail(String tekst){
        this.mail=tekst;
    }
    public String getMail(){
        return this.mail;
    }
    public void setPass(String tekst){
        this.pass=tekst;
    }
    public String getPass(){
        return this.pass;
    }
  public String[][] getDane(){
     return dane;
  }
  public void setDane(){
   db.dbm db=new db.dbm();
    db.connect();    
    String sql="select * from accounts";
      dane=db.zapytaj(sql);
  }
  public void reg(){
   try{
      db.dbm db=new db.dbm();
    db.connect();
    String sql="insert into users values('"+login+"','"+pass+"','"+mail+"');";
    db.wykonaj(sql);
    mail=pass=login="";
    db.close();
   }catch(Exception e)
   {
   }
   }

  public void zaloguj(){
 db.dbm db=new db.dbm();
    db.connect();
 
 try{
    String tmp[][] = db.zapytaj("select u_name from users where u_name='"+login+"' and u_pass='"+pass+"';");
  
      setNazwa(tmp[0][0]);

// session.setAttribute(pass, pass);
 }catch(Exception e){
     setNazwa("pass_error");
login=pass=mail="";
 }
      //  System.out.println(tmp[0][0]);
   db.close();
  }
}